/*
 * Copyright (c) 2010 CCX(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCX(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCX(China) Co.,Ltd.
 *
 * Author: Zhaoningbo
 * Date: 2011-7-21 下午04:45:31
 */
package dao;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;

public class BookDao implements Serializable {

    private static final long serialVersionUID = -3299245509122960794L;
    
    // 书名-价格 表
    private static Map<String, Integer> books = new LinkedHashMap<String, Integer>();
    static{
        books.put("T-SQL指南", new Integer(98));
        books.put("linux下C编程", new Integer(68));
        books.put("天下花卉下", new Integer(63));
        books.put("T-SQL指南（一）", new Integer(52));
        books.put("T-SQL指南（二）", new Integer(71));
    }
    
    // 根据书名 模糊匹配书目列表
    public Map<String, Integer> getBooks(String pattern){
        
        Map<String, Integer> books = new LinkedHashMap<String, Integer>();
        
        for (Map.Entry<String, Integer> entry: BookDao.books.entrySet()) {
            if (entry.getKey().toUpperCase().contains(pattern.toUpperCase())) {
                books.put(entry.getKey(), entry.getValue());
            }
        }
        
        return books;
    }
}
